<template>
  <div class="shop-management">
    <div class="header">
      <h2>店铺管理</h2>
      <div class="header-actions">
        <el-input
          v-model="searchQuery"
          placeholder="搜索店铺名称、地址或联系电话"
          style="width: 220px; margin-right: 16px;"
          clearable
        />
        <el-button type="primary" @click="handleAdd">
          <el-icon><Plus /></el-icon>
          添加店铺
        </el-button>
      </div>
    </div>

    <!-- 筛选区域 -->
    <div class="filter-section">
      <el-row :gutter="16">
        <el-col :span="4">
          <el-select
            v-model="filterForm.recommendLevel"
            placeholder="推荐等级"
            clearable
            style="width: 100%"
          >
            <el-option label="五星推荐" :value="5" />
            <el-option label="四星推荐" :value="4" />
            <el-option label="三星推荐" :value="3" />
            <el-option label="二星推荐" :value="2" />
            <el-option label="一星推荐" :value="1" />
          </el-select>
        </el-col>
        <el-col :span="4">
          <el-select
            v-model="filterForm.status"
            placeholder="店铺状态"
            clearable
            style="width: 100%"
          >
            <el-option label="营业中" value="营业中" />
            <el-option label="暂停营业" value="暂停营业" />
            <el-option label="待审核" value="待审核" />
            <el-option label="已下架" value="已下架" />
          </el-select>
        </el-col>
        <el-col :span="16">
          <el-button type="primary" @click="handleFilter">
            <el-icon><Search /></el-icon>
            筛选
          </el-button>
          <el-button @click="handleResetFilter">
            <el-icon><Refresh /></el-icon>
            重置
          </el-button>
        </el-col>
      </el-row>
    </div>

    <div class="table-container">
      <el-table
        :data="filteredShops"
        style="width: 100%"
        stripe
        border
        :header-cell-style="{ background: '#f5f7fa', color: '#606266' }"
        v-loading="loading"
      >
        <el-table-column prop="id" label="店铺ID" width="80" fixed="left" />
        
        <el-table-column prop="name" label="店铺名称" width="150" fixed="left">
          <template #default="scope">
            <div class="shop-name-cell">
              <span class="shop-name">{{ scope.row.name }}</span>
            </div>
          </template>
        </el-table-column>

        <el-table-column label="店铺图片" width="100">
          <template #default="scope">
            <div class="image-cell">
              <el-image
                v-if="scope.row.coverImage"
                :src="getImageUrl(scope.row.coverImage)"
                fit="cover"
                style="width: 60px; height: 60px; border-radius: 4px; cursor: pointer"
                :preview-teleported="true"
              />
              <div v-else class="no-image">
                <el-icon><Picture /></el-icon>
                <span>暂无图片</span>
              </div>
            </div>
          </template>
        </el-table-column>

        <el-table-column prop="address" label="地址" width="200">
          <template #default="scope">
              <span class="address-text">{{ scope.row.address }}</span>
          </template>
        </el-table-column>

        <el-table-column prop="phone" label="联系电话" width="130">
          <template #default="scope">
            <span>{{ scope.row.phone || '-' }}</span>
          </template>
        </el-table-column>

        <el-table-column label="营业时间" width="160">
          <template #default="scope">
            <div class="business-hours">
              <div>{{ scope.row.businessHours || '-' }}</div>
            </div>
          </template>
        </el-table-column>

        <el-table-column label="评分" width="170">
          <template #default="scope">
            <div class="recommend-level">
              <el-rate
                :model-value="scope.row.rating"
                disabled
                show-score
                text-color="#ff9900"
                score-template="{value}分"
              />
            </div>
          </template>
        </el-table-column>

        <el-table-column label="状态" width="115">
          <template #default="scope">
            <el-tag 
              :type="scope.row.status === '营业中' ? 'success' : scope.row.status === '暂停营业' ? 'danger' : 'warning'"
            >
              {{ scope.row.status }}
            </el-tag>
          </template>
        </el-table-column>

        <!-- <el-table-column prop="createTime" label="创建时间" width="160">
          <template #default="scope">
            <span>{{ formatDate(scope.row.createTime) }}</span>
          </template>
        </el-table-column> -->

        <el-table-column label="操作" width="160" fixed="right">
          <template #default="scope">
            <div class="action-buttons">
              <el-button
                type="primary"
                size="small"
                @click="handleEdit(scope.row)"
                :icon="Edit"
              >
                编辑
              </el-button>
              <el-button
                type="danger"
                size="small"
                @click="handleDelete(scope.row)"
                :icon="Delete"
              >
                删除
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <div class="pagination">
      <el-pagination
        v-model:current-page="currentPage"
        v-model:page-size="pageSize"
        :page-sizes="[10, 20, 50, 100]"
        :total="totalShops"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>



    <!-- 店铺编辑对话框 -->
    <el-dialog
      v-model="editDialogVisible"
      :title="editForm.id ? '编辑店铺' : '添加店铺'"
      width="800px"
      :top="'3%'"
      :close-on-click-modal="false"
    >
      <el-form :model="editForm" :rules="formRules" ref="editFormRef" label-width="100px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="店铺名称" prop="name">
              <el-input v-model="editForm.name" placeholder="请输入店铺名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="phone">
              <el-input v-model="editForm.phone" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="店铺地址" prop="address">
          <el-input v-model="editForm.address" placeholder="请输入详细地址" />
        </el-form-item>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="营业时间" prop="businessHours">
              <el-time-picker
                v-model="businessHoursRange"
                is-range
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                format="HH:mm"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="推荐等级" prop="recommendLevel">
              <el-rate v-model="editForm.recommendLevel"/>
            </el-form-item>
          </el-col>
        </el-row>

        <!-- <el-form-item label="营业备注">
          <el-input
            v-model="editForm.businessHours.note"
            placeholder="如：周一休息、节假日正常营业等"
          />
        </el-form-item> -->

        <el-form-item label="店铺状态" prop="status">
          <el-select v-model="editForm.status" style="width: 200px">
            <el-option label="营业中" value="open" />
            <el-option label="暂停营业" value="closed" />
            <el-option label="待审核" value="pending" />
            <el-option label="已下架" value="offline" />
          </el-select>
        </el-form-item>

        <el-form-item label="店铺图片">
          <div class="image-upload-section">
            <el-upload
              v-model:file-list="editForm.imageList"
              action="#"
              list-type="picture-card"
              :auto-upload="false"
              :on-change="handleImageChange"
              :on-remove="handleImageRemove"
              :before-upload="beforeImageUpload"
              multiple
            >
              <el-icon><Plus /></el-icon>
            </el-upload>
            <div class="upload-tip">
              支持 jpg、png 格式，单张图片不超过 2MB，最多上传 5 张
            </div>
          </div>
        </el-form-item>

        <el-form-item label="店铺描述">
          <el-input
            v-model="editForm.description"
            type="textarea"
            :rows="4"
            placeholder="请输入店铺描述信息"
          />
        </el-form-item>
      </el-form>
      
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="editDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="handleSave" :loading="saveLoading">保存</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, computed, onMounted, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Search, Refresh, Edit, Delete, Picture } from '@element-plus/icons-vue'
import { getFoodStorePage, deleteFoodStoreById, updateFoodStoreStatus, createFoodStore, updateFoodStore } from '@/api/shop'

// 响应式数据
const loading = ref(false)
const saveLoading = ref(false)
const searchQuery = ref('')
const currentPage = ref(1)
const pageSize = ref(10)
const totalShops = ref(0)
const editDialogVisible = ref(false)
const editFormRef = ref()

// 图片基址
const IMAGE_BASE_URL = 'http://192.168.199.178:9000/fznostalgia/foodstore'

// 获取完整图片URL
const getImageUrl = (coverImage) => {
  if (!coverImage) return 'https://via.placeholder.com/100x80'
  // 如果已经是完整URL，直接返回；否则拼接基础URL
  if (coverImage.startsWith('http')) {
    return coverImage
  }
  return `http://192.168.199.178:9000/fznostalgia/foodstore/${coverImage}`
}

// 状态映射
// const getStatusText = (status) => {
//   const statusMap = {
//     '营业中': 'open',
//     '暂停营业': 'closed',
//     '待审核': 'pending',
//     '已下架': 'offline'
//   }
//   return Object.keys(statusMap).find(key => statusMap[key] === status) || status
// }

// 反向状态映射
// const getStatusValue = (statusText) => {
//   const statusMap = {
//     '营业中': 'open',
//     '暂停营业': 'closed', 
//     '待审核': 'pending',
//     '已下架': 'offline'
//   }
//   return statusMap[statusText] || statusText
// }

// 添加用于时间范围选择的计算属性
const businessHoursRange = computed({
  get() {
    if (editForm.businessHours.open && editForm.businessHours.close) {
      return [
        new Date(`2020-01-01 ${editForm.businessHours.open}`),
        new Date(`2020-01-01 ${editForm.businessHours.close}`)
      ]
    }
    return []
  },
  set(value) {
    if (value && value.length === 2) {
      editForm.businessHours.open = formatTime(value[0])
      editForm.businessHours.close = formatTime(value[1])
    }
  }
})

// 格式化时间的辅助函数
const formatTime = (date) => {
  if (!date) return ''
  const hours = date.getHours().toString().padStart(2, '0')
  const minutes = date.getMinutes().toString().padStart(2, '0')
  return `${hours}:${minutes}`
}


// 筛选表单
const filterForm = reactive({
  recommendLevel: null,
  status: ''
})

// 店铺数据
const shops = ref([])

/**
 * 获取店铺列表
 * @returns {Promise} 店铺列表数据
 */
const getShops = async () => {
  loading.value = true
  try {
    const params = {
      pageNum: currentPage.value,
      pageSize: pageSize.value
    }
    
    // 添加搜索条件 - 支持店铺名称、地址或联系电话搜索
    if (searchQuery.value && searchQuery.value.trim()) {
      // 使用name字段进行搜索，后端应该支持模糊匹配店铺名称、地址、电话
      params.name = searchQuery.value.trim()
    }
    
    // 添加筛选条件
    if (filterForm.recommendLevel !== null && filterForm.recommendLevel !== undefined) {
      params.rating = filterForm.recommendLevel  // 后端使用rating字段
    }
    
    if (filterForm.status && filterForm.status.trim()) {
      // 将中文状态转换为数字枚举值
      const statusMap = {
        '营业中': 0,
        '暂停营业': 1,
        '已下架': 2,
        '待审核': 3
      }
      params.status = statusMap[filterForm.status]
    }
    
    console.log('发送店铺查询请求，参数:', params)
    const data = await getFoodStorePage(params)
    console.log('接收到的店铺数据:', data)
    
    // 处理返回的数据结构
    shops.value = data.records || []
    // 使用总页数计算总记录数，或者如果后端返回了total字段则直接使用
    totalShops.value = data.total || (data.pages * pageSize.value) || 0
    currentPage.value = data.pageNum || 1
    
    // 处理店铺图片URL
    shops.value = shops.value.map(shop => ({
      ...shop,
      // 处理封面图片URL - 处理URL编码的情况
      coverImage: shop.coverImage ? 
        (shop.coverImage.startsWith('http') ? 
          shop.coverImage : 
          `http://192.168.199.178:9000/fznostalgia/foodstore/${decodeURIComponent(shop.coverImage)}`
        ) : '',
      // 处理店铺图片列表
      foodStoreImages: shop.foodStoreImages ? shop.foodStoreImages.map(img => ({
        ...img,
        imageUrl: img.imageUrl ? `http://192.168.199.178:9000/fznostalgia${img.imageUrl}` : ''
      })) : []
    }))
    
    console.log('处理后的店铺数据:', shops.value)
  } catch (error) {
    console.error('获取店铺列表失败:', error)
    ElMessage.error(error.message || '获取店铺列表失败')
  } finally {
    loading.value = false
  }
}

// 编辑表单
const editForm = reactive({
  id: null,
  name: '',
  address: '',
  phone: '',
  businessHours: {
    open: '',
    close: '',
    note: ''
  },
  recommendLevel: 5,
  status: '营业中',
  category: '闽菜',
  longitude: 0.0,
  latitude: 0.0,
  priority: 1,
  images: [],
  imageList: [],
  description: ''
})

// 更新表单验证规则，移除单独的时间验证，添加整体验证
const formRules = {
  name: [
    { required: true, message: '请输入店铺名称', trigger: 'blur' },
    { min: 2, max: 50, message: '店铺名称长度在 2 到 50 个字符', trigger: 'blur' }
  ],
  address: [
    { required: true, message: '请输入店铺地址', trigger: 'blur' }
  ],
  phone: [
    { required: true, message: '请输入联系电话', trigger: 'blur' },
    { pattern: /^(\d{3,4}-?)?\d{7,8}$|^1[3-9]\d{9}$/, message: '请输入正确的电话号码', trigger: 'blur' }
  ],
  businessHours: [
    { 
      validator: (rule, value, callback) => {
        if (!editForm.businessHours.open || !editForm.businessHours.close) {
          callback(new Error('请选择营业时间'))
        } else {
          callback()
        }
      }, 
      trigger: 'change' 
    }
  ],
  recommendLevel: [
    { required: true, message: '请选择推荐等级', trigger: 'change' }
  ],
  status: [
    { required: true, message: '请选择店铺状态', trigger: 'change' }
  ]
}


// 计算属性 - 过滤店铺（现在直接使用 API 返回的数据）
const filteredShops = computed(() => {
  return shops.value
})

// 方法
const handleStatusChange = async (shop) => {
  try {
    await updateFoodStoreStatus(shop.id, shop.status)
    ElMessage.success(`店铺 ${shop.name} 状态已更新为 ${shop.status}`)
  } catch (error) {
    console.error('更新店铺状态失败:', error)
    ElMessage.error(error.message || '更新状态失败')
    // 重新获取列表以恢复原状态
    getShops()
  }
}



const formatDate = (dateString) => {
  if (!dateString) return '-'
  return new Date(dateString).toLocaleString('zh-CN')
}

const handleFilter = () => {
  currentPage.value = 1
  getShops()
  ElMessage.success('筛选完成')
}

const handleResetFilter = () => {
  filterForm.recommendLevel = null
  filterForm.status = ''
  searchQuery.value = ''
  currentPage.value = 1
  getShops()
  ElMessage.success('筛选条件已重置')
}

const handleAdd = () => {
  resetEditForm()
  editDialogVisible.value = true
}

const handleEdit = (shop) => {
  // 将后端数据转换为前端表单格式
  const formData = {
    id: shop.id,
    name: shop.name || '',
    description: shop.description || '',
    address: shop.address || '',
    phone: shop.phone || '',
    businessHours: parseBusinessHours(shop.businessHours),
    recommendLevel: shop.rating || 5,
    status: getStatusText(shop.status),
    category: getCategoryText(shop.category),
    longitude: shop.longitude || 0.0,
    latitude: shop.latitude || 0.0,
    priority: shop.priority || 1,
    images: shop.foodStoreImages ? shop.foodStoreImages.map(img => img.imageUrl) : [],
    imageList: []
  }
  
  // 如果有封面图片，添加到图片列表
  if (shop.coverImage) {
    formData.imageList.push({
      name: 'cover-image',
      url: shop.coverImage
    })
  }
  
  Object.assign(editForm, formData)
  editDialogVisible.value = true
}

// 辅助函数：将数字状态转换为文本
const getStatusText = (status) => {
  const statusMap = {
    0: '营业中',
    1: '暂停营业',
    2: '已打样',
    3: '待审核'
  }
  return statusMap[status] || '营业中'
}

// 辅助函数：将数字分类转换为文本
const getCategoryText = (category) => {
  const categoryMap = {
    0: '闽菜',
    1: '小吃',
    2: '海鲜'
  }
  return categoryMap[category] || '闽菜'
}

// 辅助函数：解析营业时间字符串
const parseBusinessHours = (businessHours) => {
  if (!businessHours) {
    return { open: '', close: '', note: '' }
  }
  
  // 尝试解析 "09:00-21:00 (周一休息)" 格式
  const match = businessHours.match(/^(\d{2}:\d{2})-(\d{2}:\d{2})(?:\s*\(([^)]+)\))?$/)
  if (match) {
    return {
      open: match[1],
      close: match[2],
      note: match[3] || ''
    }
  }
  
  // 如果不匹配标准格式，返回原始字符串作为note
  return {
    open: '',
    close: '',
    note: businessHours
  }
}

const handleDelete = async (shop) => {
  try {
    await ElMessageBox.confirm(
      `确定要删除店铺 "${shop.name}" 吗？此操作不可恢复。`,
      '确认删除',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }
    )
    
    // 调用删除API
    await deleteFoodStoreById(shop.id)
    ElMessage.success('删除成功')
    
    // 重新获取列表
    getShops()
  } catch (error) {
    if (error.message !== 'cancel') {
      console.error('删除店铺失败:', error)
      ElMessage.error(error.message || '删除失败')
    } else {
      ElMessage.info('已取消删除')
    }
  }
}

const handleSave = async () => {
  try {
    await editFormRef.value.validate()
    saveLoading.value = true
    
    if (editForm.id) {
      // 编辑店铺 - 调用真实API
      const shopData = {
        id: editForm.id,
        name: editForm.name,
        description: editForm.description || '',
        category: getCategoryValue(editForm.category), // 转换分类为数字
        businessHours: formatBusinessHours(editForm.businessHours),
        phone: editForm.phone,
        address: editForm.address,
        rating: editForm.recommendLevel || 5,
        longitude: editForm.longitude || 0.0,
        latitude: editForm.latitude || 0.0,
        priority: editForm.priority || 1,
        status: getStatusValue(editForm.status) // 转换状态为数字
      }
      
      // 获取封面图片文件（如果有新上传的图片）
      let coverImageFile = null
      if (editForm.imageList && editForm.imageList.length > 0) {
        const firstImage = editForm.imageList[0]
        if (firstImage.raw) {
          coverImageFile = firstImage.raw
        }
      }
      
      console.log('准备更新店铺，数据:', shopData)
      console.log('封面图片文件:', coverImageFile)
      
      const response = await updateFoodStore(shopData, coverImageFile)
      
      if (response.code === 200) {
        ElMessage.success('店铺信息更新成功')
        editDialogVisible.value = false
        // 重新加载店铺列表
        getShops()
      } else {
        ElMessage.error(response.msg || '更新失败')
      }
    } else {
      // 添加店铺 - 调用真实API
      const shopData = {
        name: editForm.name,
        description: editForm.description || '',
        category: getCategoryValue(editForm.category), // 转换分类为数字
        businessHours: formatBusinessHours(editForm.businessHours),
        phone: editForm.phone,
        address: editForm.address,
        rating: editForm.recommendLevel || 5,
        longitude: editForm.longitude || 0.0,
        latitude: editForm.latitude || 0.0,
        priority: editForm.priority || 1,
        status: getStatusValue(editForm.status) // 转换状态为数字
      }
      
      // 获取封面图片文件
      let coverImageFile = null
      if (editForm.imageList && editForm.imageList.length > 0) {
        const firstImage = editForm.imageList[0]
        if (firstImage.raw) {
          coverImageFile = firstImage.raw
        }
      }
      
      console.log('准备创建店铺，数据:', shopData)
      console.log('封面图片文件:', coverImageFile)
      
      const response = await createFoodStore(shopData, coverImageFile)
      
      if (response.code === 200) {
        ElMessage.success('店铺添加成功')
        editDialogVisible.value = false
        // 重新加载店铺列表
        getShops()
      } else {
        ElMessage.error(response.msg || '添加失败')
      }
    }
  } catch (error) {
    console.error('保存店铺失败:', error)
    ElMessage.error(error.message || '保存失败')
  } finally {
    saveLoading.value = false
  }
}

// 辅助函数：转换分类为数字
const getCategoryValue = (category) => {
  const categoryMap = {
    '闽菜': 0,
    '小吃': 1,
    '海鲜': 2
  }
  return categoryMap[category] !== undefined ? categoryMap[category] : 0
}

// 辅助函数：转换状态为数字
const getStatusValue = (status) => {
  const statusMap = {
    '营业中': 0,
    '暂停营业': 1,
    '已下架': 2,
    '待审核': 3
  }
  return statusMap[status] !== undefined ? statusMap[status] : 0
}

// 辅助函数：格式化营业时间
const formatBusinessHours = (businessHours) => {
  if (businessHours && businessHours.open && businessHours.close) {
    let result = `${businessHours.open}-${businessHours.close}`
    if (businessHours.note) {
      result += ` (${businessHours.note})`
    }
    return result
  }
  return businessHours || ''
}

const resetEditForm = () => {
  Object.assign(editForm, {
    id: null,
    name: '',
    address: '',
    phone: '',
    businessHours: {
      open: '',
      close: '',
      note: ''
    },
    recommendLevel: 5,
    status: '营业中',
    category: '闽菜',
    longitude: 0.0,
    latitude: 0.0,
    priority: 1,
    images: [],
    imageList: [],
    description: ''
  })
}

const handleImageChange = (file, fileList) => {
  editForm.imageList = fileList
}

const handleImageRemove = (file, fileList) => {
  editForm.imageList = fileList
}

const beforeImageUpload = (file) => {
  const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
  const isLt2M = file.size / 1024 / 1024 < 2

  if (!isJPG) {
    ElMessage.error('上传图片只能是 JPG/PNG 格式!')
    return false
  }
  if (!isLt2M) {
    ElMessage.error('上传图片大小不能超过 2MB!')
    return false
  }
  if (editForm.imageList.length >= 5) {
    ElMessage.error('最多只能上传 5 张图片!')
    return false
  }
  return true
}

const handleSizeChange = (val) => {
  pageSize.value = val
  currentPage.value = 1
  getShops()
}

const handleCurrentChange = (val) => {
  currentPage.value = val
  getShops()
}

// 监听搜索框变化，实现实时搜索
watch(searchQuery, () => {
  // 重置到第一页并重新搜索
  currentPage.value = 1
  getShops()
}, { debounce: 500 }) // 防抖500ms

// 生命周期
onMounted(() => {
  getShops()
})
</script>

<style scoped>
.shop-management {
  padding: 20px;
  background: #fff;
  border-radius: 8px;
}

.header {
  display: flex;
  /* justify-content: space-between; */
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e4e7ed;
}

.header h2 {
  margin: 0;
  color: #303133;
  font-size: 20px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  margin-left: 20px;
}

.filter-section {
  margin-bottom: 20px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 6px;
}

.table-container {
  margin-bottom: 20px;
  overflow-x: auto;
}

.shop-name-cell .shop-name {
  font-weight: 500;
  color: #409eff;
}

.image-cell {
  display: flex;
  justify-content: center;
  align-items: center;
}

.no-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #c0c4cc;
  font-size: 12px;
}

.address-text {
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.business-hours {
  font-size: 13px;
}

.hours-note {
  color: #909399;
  font-size: 12px;
  margin-top: 2px;
}

.recommend-level {
  display: flex;
  align-items: center;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.action-buttons .el-button {
  padding: 5px 8px;
}

.pagination {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.image-preview-container {
  text-align: center;
}

.image-upload-section {
  width: 100%;
}

.upload-tip {
  color: #909399;
  font-size: 12px;
  margin-top: 8px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
  }
  
  .header-actions {
    justify-content: space-between;
  }
  
  .filter-section .el-col {
    margin-bottom: 10px;
  }
  
  .action-buttons {
    flex-direction: column;
    gap: 4px;
  }
  
  .action-buttons .el-button {
    font-size: 12px;
    padding: 4px 6px;
  }
}

/* 表格滚动条样式 */
.table-container::-webkit-scrollbar {
  height: 8px;
}

.table-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}
</style>